﻿using MediatR;
using Traceability.Commont.Domains.ScratchTheFat;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;
namespace U.Enterprise.Api.Applications.SalesWeighingEXE
{
    public class SalesWeighingDelHandler:IRequestHandler<SalesWeighingDelCommond, Resqults>
    {

        private readonly IBateRepository<SalesWeighing> SalesWeighing;

        public SalesWeighingDelHandler(IBateRepository<SalesWeighing> SalesWeighing)
        {
            this.SalesWeighing = SalesWeighing;
        }

        public async Task<Resqults> Handle(SalesWeighingDelCommond request, CancellationToken cancellationToken)
        {
          var list=new Resqults() { Code=0};
            var query = SalesWeighing.GetAll().FirstOrDefault(x => x.SalesWeighingID == request.SalesWeighingID);

            if(query!=null)
            {
                query.State = 1;
                SalesWeighing.Update(query);
                list.Code = 1;
            }

            return list;

        }
    }
}
